<!DOCTYPE html>
  <html lang="en">
  <head>
      <meta charset="UTF-8">
  </head>
		<style>
			*{
    margin: 0;
    padding: 0;
}

#container{
    height: 400px;
    width:  500px;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
    border: 1px solid black;
}

#list>div {
    float: left;
}
#list{
    position: absolute;
    height: 400px;
    width:  3600px;

}

#list img{
    height: 400px;
    width:  500px;
}
.arrow {
    user-select:none;
    position: absolute;
    top:150px;
    z-index: 2;
    background-color: #aaa;
    height: 100px;
    width:  80px;
    cursor: pointer;
    opacity: 0.5;
    display: none;
    line-height: 100px;
    text-align: center;
    color: #222;
    font-size: 3em;

}
#container:hover .arrow{
    display: block;
}
 #prev{
    left:20px;
}

 #next{
    right: 20px;
}
		</style>
		<script>window.onload=function(){
    var container = document.getElementById('container');
    var list = document.getElementById('list');//获取图片容器
    var prev = document.getElementById('prev');//向前按钮
    var next = document.getElementById('next');//向后按钮
    var nowP = 1;    //显示位置
    var judge = null;    //执行权
    var speed = 0.1; // 切换速度  秒
    prev.onclick=function(){
        if(!judge){
             judge = setTimeout(function(){
                 if(nowP==1){setTimeout(function(){
                     list.style.transition="left 0s";
                    list.style.left = "-2500px";
                    nowP = 5;},speed*1000);} //当到达图片表左边缘时与动画同步切换
                 list.style.transition = "left "+speed+"s";
                move(500);
                nowP--;
                judge = null;
            },speed*1000);
        }
    };
    next.onclick=function(){
        if(!judge){
             judge = setTimeout(function(){
                 if(nowP==5){setTimeout(function(){
                     list.style.transition="left 0s";
                    list.style.left = "-500px";
                    nowP = 1;},speed*1000);} //当到达图片表右边缘时与动画同步切换
                list.style.transition = "left "+speed+"s";
                move(-500);
                nowP++;
                judge = null;
            },speed*1000);
        }

    };

    function move(num){
        var term = parseInt(list.style.left) + num ;
        list.style.left = term+"px";
    }

    var roll= setInterval(function(){
        next.onclick();
    },2000);

    container.onmouseenter=function(){
        clearInterval(roll);
    };

    container.onmouseleave=function()
        {
        roll=setInterval(function(){
        next.onclick();
        },2000);
    };


};</script>
  <body>
    <div id="container">
        <div id="list" style="left: -500px">
             <div><img src="https://t9.baidu.com/it/u=865180044,3526254683&fm=193" alt=""></div>
             <div><img src="https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=3273903337,484472162&fm=11&gp=0.jpg" alt=""></div>
             <div><img src="https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=3253160757,2308981080&fm=26&gp=0.jpg" alt=""></div>
             <div><img src="https://t9.baidu.com/it/u=4210315996,3941006054&fm=193" alt=""></div>
         </div>
 
       <div class="arrow" id="prev">&lt;</div>
        <div class="arrow" id="next">&gt;</div>
 
 
     </div>        
 
 </body>    
 
 </html>